//
//  UIView+SZ.m
//  01-美图-搭建
//
//  Created by Zahi on 2017/6/8.
//  Copyright © 2017年 Zahi. All rights reserved.
//

#import "UIView+SZ.h"

@implementation UIView (SZ)



#pragma mark - size
- (CGSize)sz_size
{
    return self.frame.size;
}

- (void)setSz_size:(CGSize)size
{
    CGRect oldFrame = self.frame;
    
    oldFrame.size = size;
    
    self.frame = oldFrame;
}

#pragma mark - origin
- (CGPoint)sz_origin
{
    return self.frame.origin;
}

- (void)setSz_origin:(CGPoint)origin
{
    CGRect oldFrame = self.frame;
    
    oldFrame.origin = origin;
    
    self.frame = oldFrame;
}

#pragma mark - width
- (CGFloat)sz_width
{
    return self.frame.size.width;
}

- (void)setSz_width:(CGFloat)width
{
    CGRect oldFrame = self.frame;
    
    oldFrame.size.width = width;
    
    self.frame = oldFrame;
}

#pragma mark - height
- (CGFloat)sz_height
{
    return self.frame.size.height;
}

- (void)setSz_height:(CGFloat)height
{
    CGRect oldFrame = self.frame;
    
    oldFrame.size.height = height;
    
    self.frame = oldFrame;
}

#pragma mark - x

- (CGFloat)sz_x
{
    return self.frame.origin.x;
}

- (void)setSz_x:(CGFloat)x
{
    CGRect oldFrame = self.frame;
    
    oldFrame.origin.x = x;
    
    self.frame = oldFrame;
}
- (CGFloat)sz_maxX
{
    return CGRectGetMaxX(self.frame);
}
- (void)setSz_maxX:(CGFloat)maxX
{
    CGRect oldFrame = self.frame;
    
    oldFrame.origin.x = (maxX - CGRectGetWidth(self.frame));
    
    self.frame = oldFrame;
}

#pragma mark - y
- (CGFloat)sz_y
{
    return self.frame.origin.y;
}

- (CGFloat)sz_maxY
{
    return CGRectGetMaxY(self.frame);
}
- (void)setSz_maxY:(CGFloat)maxY
{
    CGRect oldFrame = self.frame;
    
    oldFrame.origin.x = (maxY - CGRectGetHeight(self.frame));
    
    self.frame = oldFrame;
}

- (void)setSz_y:(CGFloat)y
{
    CGRect oldFrame = self.frame;
    
    oldFrame.origin.y = y;
    
    self.frame = oldFrame;
}

#pragma mark - center
- (CGFloat)sz_centerX
{
    return self.center.x;
}
- (void)setSz_centerX:(CGFloat)centerX
{
    CGRect oldFrame = self.frame;
    
    oldFrame.origin.x = (centerX - CGRectGetWidth(self.frame) * 0.5);
    
    self.frame = oldFrame;
    
}
- (CGFloat)sz_centerY
{
    return self.center.y;
}
- (void)setSz_centerY:(CGFloat)centerY
{
    CGRect oldFrame = self.frame;
    
    oldFrame.origin.y = (centerY - CGRectGetHeight(self.frame) * 0.5);
    
    self.frame = oldFrame;
}


@end
